#ifndef SAW_H
#define	SAW_H

#include <cstdlib>
#include <unordered_map>

class SAW {
public:
    SAW(unsigned long stepSizes[], size_t amountStepSizes, unsigned int seed);
    long* walk();
private:
	typedef
	std::unordered_map<long,
	std::unordered_map<long, bool> > sparseArray;
	
	sparseArray map;
    static const long startX = 0;
    static const long startY = 0;
    long minX;
    long maxX;
    long minY;
    long maxY;
    
    unsigned long directions;
    unsigned long stepSize;
    unsigned long* stepSizes;
    size_t stepSizeCounter;
    size_t amountStepSizes;
    bool* possibleDirections;

    unsigned long calculatePossibleDirections(long x, long y);
    void doStep(long oldX, long oldY, long newX, long newY);
    bool canGoNord(long x, long y);
    bool canGoEast(long x, long y);
    bool canGoSouth(long x, long y);
    bool canGoWest(long x, long y);
    unsigned long newStepSize();
    unsigned long getDirection(unsigned int number);
};

#endif	/* RANDOMWALK_H */
